package com.yh.csx.demo.controller;
import com.yh.csx.bsf.redis.RedisProvider;
import com.yh.csx.demo.conf.DoubtApiProperties;
import com.yh.csx.demo.model.po.Customer;
import com.yh.csx.demo.model.request.CustomerAddReq;
import com.yh.csx.demo.model.response.CommonResponse;
import com.yh.csx.demo.model.response.CustomerDetailsResp;
import com.yh.csx.demo.provider.CustomerProvider;
import com.yh.csx.demo.service.CustomerService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;

@Slf4j
@RestController
public class CustomerController extends BaseController implements CustomerProvider {

	@Autowired
	private CustomerService customerService;

	@Resource
	DoubtApiProperties propterties;

	public CommonResponse<CustomerDetailsResp> getCustomer(Long customerId) {		
			return super.visit(() -> {
				log.info("aaaa");
				Customer customer = customerService.getCustomer(customerId);	
				// 查询客户类型
				String customerType = "MOCK";
				CustomerDetailsResp cusP =new CustomerDetailsResp();
				BeanUtils.copyProperties(customer, cusP);				
				cusP.setType(customerType);
				return cusP;
			});
	

	}

	@GetMapping("/echo")
	@ApiOperation("禁用/启用")
	public CommonResponse<Object> echo(String str) {
		return CommonResponse.success("success", propterties);

	}
	
	@GetMapping("/sendSMS")
	@ApiOperation("发送短信")
	public CommonResponse<Object> sendSms(String phone,String conetent,String systemCode){
			return CommonResponse.success("success", propterties);

	}
	@Override
	public CommonResponse addCustomer(CustomerAddReq req) {
		// TODO Auto-generated method stub
		return null;
	}

}